class App {
    constructor(id) {
        this.$app = $('#' + id)
        this.$text = $(`
            <div class="content">
                
            </div>
        `)
        this.$moive = $(`
           <div id="J_prismPlayer" class="video">
           
           
           </div>
        `)

        this.$moive.hide()
        console.log(this.$app)
        this.$app.append(this.$text)
        this.$app.append(this.$moive)
        this.render()
    }

    render() {
        var player = new Aliplayer({
            id: 'J_prismPlayer',
            source: 'http://rmztbozkw.hn-bkt.clouddn.com/%E7%88%B1%E5%9C%A8%E9%BB%8E%E6%98%8E%E7%A0%B4%E6%99%93.mkv\n',
            //播放地址，可以是第三方点播地址，或阿里云点播服务中的播放地址。
            width: "100%",
            height: "100%",
            textTracks:
                [{ kind: 'subtitles', label: '英文（美国）', src:
                        'http://rmztbozkw.hn-bkt.clouddn.com/Before.Sunrise.1995.cht.vtt',
                    srclang: 'en-US' }]
            ,
        }, function (player) {
            console.log('The player is created.')
        });

        let outer = this
        setInterval(function () {
            let due = Date.parse("2022-12-16T09:00:00")
            let leftTime = due.valueOf() - Date.now().valueOf()
            let leftd = Math.floor(leftTime / (1000 * 60 * 60 * 24)),  //计算天数
                lefth = Math.floor(leftTime / (1000 * 60 * 60) % 24),  //计算小时数
                leftm = Math.floor(leftTime / (1000 * 60) % 60),  //计算分钟数
                lefts = Math.floor(leftTime / 1000 % 60);  //计算秒数
            let s = `距离电影开场还有${leftd}天${lefth}时${leftm}分${lefts}秒`
            outer.$text.text(s)
            if (leftTime < 0) {
                outer.$text.hide()
                outer.$moive.show()
            }
        }, 1000)
    }
}

export {
    App
}